<?php
	include_once 'isLogin.php';
	$groupc=new group(); //服务类
	$id=$_GET['id'];
	$smarty->assign('id',$id);
	$table="admin_topic";
	$admin_id=$_COOKIE['admin_id'];

	//修改
	if($id!='' && $id!=null){
		$row=$groupc->topic_info($id);
		$smarty->assign('row',$row);
	}
	

	if($_POST['submit']){
		$arr= array('topic' =>$_POST['topic'],);	//话题

		if($id!='' && $id!=null){//update
			$res=$commonc->update($table, $arr, "id='".$id."'");
		}else{//insert
			$arr['create_time']=time();
			$arr['admin_id']=$admin_id;
			$res=$commonc->insert($table,$arr);		
		}
		
		if($res){
			$msg="操作成功";
			$href="admin_topic_list.php";
		}else{
			$msg="操作失败";
			$href="admin_topic_list.php";
		}
		echo $commonc->submitAlert($msg,$href);
		exit;
	}


	$smarty->display("admin_topic_add.html");
?>